package com.example.spring2.pk5;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @ ConfigurationProperties:表示使用Bean对象读取配置项
 *      prefix:   表示配置文件中多个key的公共开始部分。
 *                比如app.name，这里app就前缀
 * **/
@Configuration(proxyBeanMethods = false)
@ConfigurationProperties(prefix = "app")
public class AppBean {
    // key的名称与属性名相同，调用属性setXXX方法给属性赋值
    // 非static方法
    private String name;
    private String owner;
    private Integer port;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    @Override
    public String toString(){
        return "Appbean{"+
                "name='" + name + '\'' +
                "，owner='" + owner +'\''  +
                "，port=" + port +
                '}';
    }
}
